<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="../js/infobase.js"></script>
        <script type="text/javascript" src="../js/channeltype.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/iColorPicker.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            b.b1{display:block;padding:1px 5px 1px 5px;border:1px solid #E0E0E0;}
        </style>
    </head>
    <body>
        <div id="panel">
            <form id="queryFrm">
                <h3 class="s1">内容信息查询<a href="javascript:ut.swap('facade');">[±]</a></h3>
                <table border="0" cellspacing="0" cellpadding="0" id="facade">
                    <tr>
                        <td width="2%" height="34">&nbsp;</td>
                        <td width="7%" class="r">发布状态：</td>
                        <td width="22%">
                            <select id="pubstate" name="pubstate" style="width:100px;">
                                <option value=""></option>
                                <option value="1">1-是-</option>
                                <option value="0">0-否-</option>
                            </select>
                            <span class="r">
                                <input onClick="INFO.updatePubState();" type="button" id="updateBtn1" value="更新">
                            </span></td>
                        <td class="r">发布时间：</td>
                        <td width="29%">
                            从 <input type="text" id="pubBeginTime" name="pubBeginTime" value="" maxlength="19" style="width:100px;" onclick="cdpn('pubBeginTime');"/>
                            到 <input type="text" id="pubEndTime" name="pubEndTime" value="" maxlength="19" style="width:100px;"  onclick="cdpn('pubEndTime');"/>
                        </td>
                        <td width="9%" class="r">标题颜色：</td>
                        <td colspan="2">
                            <input type="text" name="tcolor" id="tcolor" tabindex="2" class="iColorPicker" style="width:80px;">
                            <input type="button" value="清除" onclick="$('#tcolor').val('');"/>
                            <input onClick="INFO.updateTColor();" type="button" id="updateBtn5" value="更新">

                        </td>
                    </tr>
                    <tr>
                        <td height="33">&nbsp;</td>
                        <td class="r">信息类型：</td>
                        <td><script>out_infotype();</script></td>
                        <td class="r">结束时间：</td>
                        <td>从
                            <input type="text" id="stopBeginTime" name="stopBeginTime" value="" maxlength="19" style="width:100px;" onclick="cdpn('stopBeginTime');"/>
                            到
                            <input type="text" id="stopEndTime" name="stopEndTime" value="" maxlength="19" style="width:100px;"  onclick="cdpn('stopEndTime');"/></td>
                        <td>&nbsp;</td>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td height="33">&nbsp;</td>
                        <td class="r">信息ID：</td>
                        <td><input type="text" id="infoid" name="infoid" value=""  style="width:120px;"  onclick="this.value=''"/></td>
                        <td class="r">标识类别：</td>
                        <td><script>out_tflag();</script><span class="r">
                                <input onClick="INFO.updateTFlag();" type="button" id="updateBtn4" value="更新">
                            </span></td>
                        <td class="r">评论状态：</td>
                        <td colspan="2"><select id="iscmt" name="iscmt" style="width:100px;">
                                <option value=""></option>
                                <option value="0">0-关闭-</option>
                                <option value="1">1-开放-</option>
                            </select>
                            <input onClick="INFO.updateCmtState();" type="button" id="updateBtn2" value="更新">
                        </td>
                    </tr>
                    <tr>
                        <td height="33">&nbsp;</td>
                        <td class="r">查看次数：</td>
                        <td>从 <input type="text" id="beginHitNum" name="beginHitNum" value=""  style="width:50px;"/>到
                            <input type="text" id="endHitNum" name="endHitNum" value=""  style="width:50px;"/></td>
                        <td class="r">板块类别：</td>
                        <td><script>out_select('channeltype');</script><span class="r">
                                <input onClick="INFO.updateChannelCatalog();" type="button" id="updateBtn3" value="更新板块/类别">
                            </span></td>
                        <td class="r">每页显示：</td>
                        <td width="13%"><select name="listsize" id="listsize">
                                <option value="10">10条</option>
                                <option value="20">20条</option>
                                <option value="50">50条</option>
                            </select></td>
                        <td width="11%"><input name="rownum" id="rownum" value="" type="hidden" />
                            <input name="crow" id="crow" value="" type="hidden" />
                            <input name="currpage" id="currpage" value="" type="hidden" /></td>
                    </tr>
                    <tr>
                        <td height="33">&nbsp;</td>
                        <td class="r">权重范围：</td>
                        <td>从 <input type="text" id="beginWeight" name="beginWeight" value=""  style="width:50px;"/>到
                            <input type="text" id="endWeight" name="endWeight" value=""  style="width:50px;"/></td>
                        <td class="r">信息类别：</td>
                        <td> <input type="hidden" name="cid" id="cid" value=""/> 
                            ctp:
                            <input type="text" name="ctp" id="ctp" value="" style="width:100px;" readonly="readonly" onclick="selectCatelogs();"/> 
                            <input type="button" value="清空" onclick="$('#cid').val('');$('#ctp').val('');"/> 
                        </td>
                        <td class="r">标题关键词：</span></td>
                        <td colspan="2"><input id="titleKeyword" name="titleKeyword" value="" maxlength="20" style="width:120px;" onClick="this.value=''"/></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td class="r">选择时间：</td>
                        <td><input type="text" id="pubtime" name="pubtime" value="" maxlength="19" style="width:100px;" onClick="cdpn('pubtime');"/>
                            <input onClick="INFO.updatePubTime();" type="button" id="updateBtn6" value="更新发布时间"></td>
                        <td class="r">选择时间：</td>
                        <td><input type="text" id="endtime" name="endtime" value="" maxlength="19" style="width:100px;" onClick="cdpn('endtime');"/>
                            <input onClick="INFO.updateEndTime();" type="button" id="updateBtn7" value="更新结束时间"></td>
                        <td colspan="2" class="r"><input onClick="INFO.list(1, 0);" type="button" class="button small orange" id="submitBtn" value="Φ 查询">                          <input onClick="INFO.del();" type="button" class="button small gray" id="delBtn" value="x 删除"></td>
                        <td class="r">&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>


        <div class="databox">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="4%">&nbsp;<a href="javascript:ut.swapsel('sel');">反选</a></th>
                    <th width="27%">标题/ID/类别</th>
                    <th width="5%">PID</th>
                    <th width="12%">发布/结束时间</th>
                    <th width="7%">类型</th>
                    <th width="7%">板块</th>
                    <th width="5%">发布</th>
                    <th width="5%">评论</th>
                    <th width="5%">标识</th>
                    <th width="6%">查看</th>
                    <th width="8%">权重</th>
                    <th width="7%">操作</th>
                </tr>
                <tbody class="tbchg" id="datalist"></tbody>
            </table>
</div>
        <div class="page" id="page"></div>

        <div style="display:block;clear:both;width:98%;height:50px;">&nbsp;</div>
        
<script id="listTpl" type="text/html">
{%  for(var k in list){ var e = list[k]; %}
    <tr>
      <td><input name="sel" type="checkbox" value="{%=e.infoid%}"/></td>
      <td>
        <b onclick="INFO.viewInfo('{%=e.infoid%}');" style="color:{%=e.tcolor%};font-size:13px;font-weight:600;cursor:pointer;">
            {%=e.title%}
        </b>
        <br/>
        <span class="s1">id:  {%=e.infoid%} , ctp:{%=e.ctp%}</span>
      </td>
      <td>{%=e.pid%}</td>
      <td>{%=highlightNextTime(e.pubtime)%}<br/>  {%=highlightOverTime(e.endtime)%} </td>
      <td>{%=getInfoType(e.infotype)%} </td>
      <td>{%=getChannelType(e.channeltype)%} </td>
      <td>{%=getPubState(e.pubstate)%} </td>
      <td>{%=getCmtState(e.iscmt)%} </td>
      <td>{%=getTitleFlag(e.tflag)%} </td>
      <td>{%=e.hitnum%} </td>
      <td><input type="text" id="w{%=e.infoid%}" value="{%=e.weight%}" maxlength="8" onchange="INFO.updateWeight('{%=e.infoid%}', this.value);" style="width:50px;"/> </td>
      <td><a href="javascript:;" onclick="INFO.editInfobase('{%=e.infoid%}');">编辑</a></td>
    </tr>
{%}%}
</script>


        <script type="text/javascript">
            var $lsout = $('#datalist');
            var $ls = $('#listsize');
            var $rownum = $('#rownum');
            var $crow=$('#crow');
            var $curpage=$('#currpage');
            var INFO={
                list:function(pgno,r){
                    var ls = parseInt($ls.val());
                    var step =10;
                    var cr = (ls * ( pgno - 1 ));
                    $rownum.val(r);
                    $crow.val(cr);
                    $curpage.val(pgno);
                    var params = ut.getFormData('#queryFrm');
                    params._t=ut.r();
                    $.get('../app/infobase/list_factor.shtm',params,function(d){
                        var x = d;
                        rn=x.rownum;
                        $rownum.val(rn);
                        if(rn>0){
                            ut.outpage(pgno, rn, 'INFO.list','page', ls, step);
                            $lsout.html(template.render('listTpl',x));
                        }else{
                            $lsout.html('<tr><td colspan="11">暂无数据.</td></tr>');
                            $('#page').html('');
                        }
                    }
                );
                },
                del:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要删除的信息.');return;}
                    if(!window.confirm("确定删除么?执行后不可恢复."))return;
                    $.get('../app/infobase/delete_batch.shtm?t='+ut.r(), "ids="+ida, function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('删除成功.已删除记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('删除失败. '+r);
                        }
                    });
                },
                updatePubState:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var st = $('#pubstate').val();
                    if(va.isnull(st)){ut.m('请选择发布状态.');return;}
                    var p = {'ids':ida,'pubstate':st};
                    $.get('../app/infobase/update_pubstate.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updateCmtState:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var st = $('#iscmt').val();
                    if(va.isnull(st)){ut.m('请选择评论状态.');return;}
                    var p = {'ids':ida,'iscmt':st};
                    $.get('../app/infobase/update_cmtstate.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updateTFlag:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var tf = $('#tflag').val();
                    if(va.isnull(tf)){ut.m('请选择标识类别.');return;}
                    var p = {'ids':ida,'tflag':tf};
                    $.get('../app/infobase/update_tflag.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updateTColor:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var tc = $('#tcolor').val();
                    if(va.isnull(tc)){tc='-'}
                    var p = {'ids':ida,'tcolor':tc};
                    $.get('../app/infobase/update_tcolor.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updatePubTime:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var t  = $('#pubtime').val();
                    if(!va.datetime(t)){ut.m('请选择发布时间！');return;}
                    var p = {'ids':ida,'pubtime':ut.parseMs(t)};
                    $.get('../app/infobase/update_pubtime.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updateEndTime:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var t  = $('#endtime').val();
                    if(!va.datetime(t)){t='';}
                    var p = {'ids':ida,'endtime':ut.parseMs(t)};
                    $.get('../app/infobase/update_endtime.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });
                },
                updateWeight:function(id,w){
                    if(!va.isint(w) || w<=0){return;}
                    var p={'infoid':id,'weight':w};
                    $.get('../app/infobase/update_weight.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            TxBox.wait('更新成功！');
                        }else{
                            TxBox.wait('更新失败！');
                        }
                        TxBox.hide();
                    });
                },
                updateChannelCatalog:function(){
                    var ida = ut.getselv('sel');
                    if(va.isnull(ida)){ut.m('请选择需要更新的信息.');return;}
                    var ct = $('#channeltype').val();
                    var cid = $('#cid').val();
                    var ctp = $('#ctp').val();
                    if(!va.mint(ct) || !va.isint(cid)){ut.m('请选择板块、信息类别.');return;}
                    var p = {'ids':ida, 'cid':cid, 'ctp':ctp, 'channeltype':ct};
                    $.get('../app/infobase/update_channel_catelog.shtm',$.param(p), function(x){
                        var r = $.trim(x);
                        if(va.tint(r)){
                            ut.m('更新成功.已更新记录数为'+r);
                            INFO.list($curpage.val(),0);
                        }else{
                            ut.m('更新失败. '+r);
                        }
                    });   
                },
                editInfobase:function(id){
                    win.open('info_edit.html?infoid='+id);
                },
                viewInfo:function(id){
                    window.open(WOW_DOMAIN+def.ctx+'/info/view/'+id,'_blank');
                }
            };

            function selectCatelogs(){
                var ct = $('#channeltype').val();
                if(!va.mint(ct)){
                    TxBox.alert('请先选择板块.');
                    return;
                }
                TxBox.winpop(250,350,'类目选择', 'catalogs_select_pop.html?channeltype='+ct);
            };

            function reloadCatData(cid,ctp){
                $('#cid').val(cid);
                $('#ctp').val(ctp);
                $('#ctp_name_path').text(cid+';'+ctp);
                TxBox.closeWinpop();
            };
            var g_curTime = (new Date()).getTime();
            // 将过期的信息时间标注为高亮
            function highlightOverTime(t){
                
                var timeStr = ut.parseDate(t,16);
                if(t>1000 && (Number(t)-g_curTime)<0){
                    return '<span style="color:red">'+timeStr+'</span>';
                }
                return timeStr;
            };
            function highlightNextTime(t){
                var timeStr = ut.parseDate(t,16);
                if(t>1000 && (Number(t)-g_curTime)>0){
                    return '<span style="color:blue">'+timeStr+'</span>';
                }
                return timeStr;
            };
            
            template.helper('highlightNextTime',highlightNextTime);
            template.helper('highlightOverTime',highlightOverTime);
            template.helper('getInfoType',getInfoType);
            template.helper('getChannelType',getChannelType);
            template.helper('getPubState',getPubState);
            template.helper('getCmtState',getCmtState);
            template.helper('getTitleFlag',getTitleFlag);
 
            jQuery(function(){
                $('#channeltype').val('0').attr('readonly','readonly');
                $('#channeltype').change(function(){
                    $('#cid').val('');
                    $('#ctp').val('');
                    if($('#channeltype').val()!='0'){
                        $('#channeltype').val('0');
                    }
                });
            });
        </script>
    </body>
</html>